home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1988 / Jan 88 / Unsafe use of handles 1⁄14 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.3 KB  |  37 lines  |  [TEXT/GEOL]

  1. Item    2129697                         14-Jan-88        18:40
  2.  
  3. From:   WILSON6                         Wilson, Dave - Personal Concepts
  4.  
  5. To:     MACAPP$                         MacApp Interest List
  6.  
  7. Sub:    Unsafe use of handles
  8.  
  9. The MPW Pascal compiler currently checks for handles used as VAR parameters in
  10. Function and Procedure calls, and warns you about "Unsafe use of a handle".
  11. This of course is also checked for fields of an object.  This is good, but
  12. doesn't go far enough, because there are numerous other opportunities to screw
  13. up that I do not believe the compiler will catch.  These are covered in
  14. Knaster's first book in detail.
  15.  
  16. As nearly as I can understand, the following might be dangerous:
  17.  
  18. ROMCallABC(fEnclosingRect);
  19.     Data structures larger than 4 bytes have their address pushed on the stack
  20. - even if they are being passed by value.
  21.  
  22. SELF.fShapeList := NewList;
  23.        The function call may move the object on the heap, after the address of
  24. the data field is computed.
  25.  
  26. aShape := MyShapeFactory(x,y,z);
  27.     Note that this could be a problem even if MyShapeFactory did not allocate
  28. memory - IF it were in a nonresident CODE segment that had to be loaded into
  29. memory.
  30.  
  31. Am I being too paranoid, or are these potential problems? If so, then the
  32. compiler should be changed to warn you about these also.
  33.  
  34. Dave
  35.  
  36.  
  37.